package com.hong.bean.aspect;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

@Slf4j
@Component
public class RequestInterceptor implements HandlerInterceptor {


    private List<String> uri = Arrays.asList("/swagger-ui/index.html","/","login","logout");


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String authorization = request.getHeader("Authorization");

        String requestURI = request.getRequestURI();

//        if (!Objects.equals(authorization,"123456") &&  !uri.contains(requestURI)){
//            return false;
//        }
//
//        log.info("Authorization: {}",authorization);

        return true;
    }
}
